import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改

public class Main {
    //都不是返回0
    //是质数返回1
    //是合数返回2
    public static int isZ(int x) {
        if(x > 1) {
            for (int i = 2; i <= Math.sqrt(x); i++) {
                if(x % i == 0)
                    return 2;
            }
            return 1;
        }
        return 0;
    }
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        //在此输入您的代码...
        int n = scan.nextInt();
        //相邻的i、j不是质数就是合数
        int[] arr = new int[n];
        int max = 0;
        for(int i = 0;i < n;i++) {
            arr[i] = scan.nextInt();
        }
        ////////////////////////////////
        int sum = 0;
        for(int i = 0;i < n;i++) {
            int key = isZ(arr[i]);
            switch (key) {
                case 1:
                    sum++;
                    max = Math.max(sum,max);
                    if(i + 1 < n && isZ(arr[i+1]) != 1) {
                        sum = 0;
                    }
                    break;
                case 2:
                    sum++;
                    max = Math.max(sum,max);
                    if(i + 1 < n && isZ(arr[i+1]) != 2){
                        sum = 0;
                    }
            }
        }
        System.out.println(max);
        scan.close();
    }
}